<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>shmctl</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_008_552">&nbsp;</a>NAME</h4><blockquote>
shmctl - shared memory control operations
</blockquote><h4><a name = "tag_000_008_553">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="sysshm.h.html">sys/shm.h</a>&gt;

int shmctl(int <i>shmid</i>, int <i>cmd</i>, struct shmid_ds *<i>buf</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_008_554">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>shmctl()</i>
function provides a variety of shared memory control operations as specified
by
<i>cmd</i>.
The following values for
<i>cmd</i>
are available:
<dl compact>

<dt>IPC_STAT<dd>
Place the current value of each member of the
<b>shmid_ds</b>
data
structure associated with
<i>shmid</i>
into the structure pointed to by
<i>buf</i>.
The contents of the structure are defined in
<i><a href="sysshm.h.html">&lt;sys/shm.h&gt;</a></i>.

<dt>IPC_SET<dd>
Set the value of the following members of the
<b>shmid_ds</b>
data structure
associated with
<i>shmid</i>
to the corresponding value found
in the structure pointed to by
<i>buf</i>:
<pre>
<code>
shm_perm.uid
shm_perm.gid
shm_perm.mode    low-order nine bits
</code>
</pre>

IPC_SET can only be executed by a process that has an
effective user ID equal to either that of a process
with appropriate privileges or
to the value of
<b>shm_perm.cuid</b>
or
<b>shm_perm.uid</b>
in the
<b>shmid_ds</b>
data structure associated with
<i>shmid</i>.

<dt>IPC_RMID<dd>
Remove the shared memory identifier specified by
<i>shmid</i>
from the system and destroy the shared
memory segment and
<b>shmid_ds</b>
data structure associated with it.
IPC_RMID can only be executed by a process that has an
effective user ID equal to either that of a process with
appropriate privileges or
to the value of
<i>shm_perm.cuid</i>
or
<i>shm_perm.uid</i>
in the
<b>shmid_ds</b>
data structure associated with
<i>shmid</i>.

</dl>
</blockquote><h4><a name = "tag_000_008_555">&nbsp;</a>RETURN VALUE</h4><blockquote>
Upon successful completion,
<i>shmctl()</i>
returns 0.  Otherwise, it returns -1 and
<i>errno</i>
will be set to indicate the error.
</blockquote><h4><a name = "tag_000_008_556">&nbsp;</a>ERRORS</h4><blockquote>
The
<i>shmctl()</i>
function will fail if:
<dl compact>

<dt>[EACCES]<dd>
The argument
<i>cmd</i>
is equal to IPC_STAT and the calling process does not have read permission,
see
<a href="ipc.html">IPC</a>.

<dt>[EINVAL]<dd>
The value of
<i>shmid</i>
is not a valid shared memory identifier,
or the value of
<i>cmd</i>
is not a valid command.

<dt>[EPERM]<dd>
The argument
<i>cmd</i>
is equal to IPC_RMID or IPC_SET
and the effective user ID of the calling process
is not equal to that of
a process with appropriate privileges
and it is not equal to the value of
<b>shm_perm.cuid</b>
or
<b>shm_perm.uid</b>
in the data structure associated with
<i>shmid</i>.

</dl>
<p>
The
<i>shmctl()</i>
function may fail if:
<dl compact>

<dt>[EOVERFLOW]<dd>
The <i>cmd</i> argument is IPC_STAT and the <b>gid</b> or <b>uid</b> value is too
large to be stored in the structure pointed to by the <i>buf</i> argument.

</dl>
</blockquote><h4><a name = "tag_000_008_557">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_008_558">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
The POSIX Realtime Extension defines alternative interfaces for interprocess communication.
Application developers who need to use IPC should design their
applications so that modules using the IPC routines described in
<a href="ipc.html">IPC</a>
can be easily modified to use the alternative interfaces.
</blockquote><h4><a name = "tag_000_008_559">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_008_560">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="shmat.html">shmat()</a></i>,
<i><a href="shmdt.html">shmdt()</a></i>,
<i><a href="shmget.html">shmget()</a></i>,
<i><a href="shm_open.html">shm_open()</a></i>,
<i><a href="shm_unlink.html">shm_unlink()</a></i>,
<i><a href="sysshm.h.html">&lt;sys/shm.h&gt;</a></i>,
<a href="ipc.html">IPC</a>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from Issue 2 of the SVID.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

